home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * testkeys.c:
- *
- * Test program for Tom Wurzbach's extended
- * scancodes function package
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- extern int getkey(void);
- extern int getshift(void);
- extern int kbhit(void);
-
- union KEY
- {
- char ASCII_code;
- int scan_code;
- };
-
- union SHIFT
- {
- int shift;
- struct
- {
- unsigned rshift : 1;
- unsigned lshift : 1;
- unsigned ctrl : 1;
- unsigned alt : 1;
- unsigned scroll : 1;
- unsigned num : 1;
- unsigned caps : 1;
- unsigned ins : 1;
- } bit;
- };
-
- main()
- {
- union KEY k;
- union SHIFT s;
-
- puts("Press keys, Ctrl-Break to exit");
-
- while (1)
- {
- k.scan_code = getkey();
- s.shift = getshift();
- printf("0x%04x 0x%02x ", k.scan_code, k.ASCII_code);
- if (s.bit.rshift) printf("RShift ");
- if (s.bit.lshift) printf("LShift ");
- if (s.bit.ctrl) printf("Ctrl ");
- if (s.bit.alt) printf("Alt ");
- if (s.bit.scroll) printf("Scroll ");
- if (s.bit.num) printf("Num ");
- if (s.bit.caps) printf("Caps ");
- if (s.bit.ins) printf("Ins ");
-
- printf("\n");
- }
- }
-